﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HA.ModFlow.Domain.DomainLayer
{
    [Serializable]
    public class Evapotranspiration : MFBoundary, ICloneable 
    {
        public Evapotranspiration(int nrows, int ncolumns, int nlayers, int nPeriods):base(nrows,ncolumns,nlayers,nPeriods)
        {
            this._periods = new List<EVTPeriod>();

            for (int i = 0; i < nPeriods; i++)
            {

                EVTPeriod ep = new EVTPeriod(nrows, ncolumns);
             
                this._periods.Add(ep);
            }
        }

        List<EVTPeriod> _periods;

        public List<EVTPeriod> Periods
        {
            get { return _periods; }
            set { _periods = value; }
        }

        EVTOPTION _option;

        public EVTOPTION Option
        {
            get { return _option; }
            set { _option = value; }
        }

        public object Clone()
        {
            Evapotranspiration newEVT = (Evapotranspiration)this.MemberwiseClone();
            return newEVT;
        }

        public void OnResetSperiods(int nPeriods)
        {


            if (this.NPeriods == nPeriods)
            {
                return;
            }

            if (this.NPeriods < nPeriods)
            {
                int nSub = nPeriods - this.NPeriods;

                for (int i = 0; i < nSub; i++)
                {
                   this.Periods.Add(new EVTPeriod(this.RCount, this.CCount));
                }
            }

            else
            {
                int nSub = this.NPeriods - nPeriods;
                this.Periods.RemoveRange(nPeriods, nSub);
            }

            this.NPeriods = nPeriods;
        } 
    }
}
